<div class="index dashboard route-animated">
    <div class="tit clearfix">
        <div class="head fl"><i class="icon-head-l"></i></div> 
        <div class="info fl"><p class="hello">
            <span>晚上好, </span><span class="usernick"></span></p> 
            <p id="lgtype" class="lgtype">您上次登录IP：<span>124.104.197.220</span>，时间：<span>2017-08-29 15:08:02</span>本次登录IP：<span>27.154.58.158</span>（<a href="login.html">不是您登录的？请点这里</a>)
            </p>
        </div>
    </div> 
    
    <div class="agenturl">
        <div class="mintit"><i class="icon-light"></i>您当前的身份是<span>代理</span>，以下是您的推广链接
        </div> 
        <div class="list">
            <p><a href="#" style="display: inline;"><span></span></a> 
            <button id="copyAgentUrl">复制推广链接</button></p>
        </div>
    </div>

    <div class="money">
        <div class="mintit">
            <i class="icon-money"></i>代理钱包：<span class="balance">0</span>
            <span style="color: brown;" class="balance-zero-clue">（可提现金额不足）</span>
        </div> 
        
        <div class="mintit">
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 未结算金额：<span class="weijie-balance">0</span>
        <span><span style="color: brown;">（未达到结算条件）</span></span> 
        </div>
    </div> 
    
    <h2 style="font-size: 18px;">
        结算明细： 
    </h2> 

    <div class="filter">
        <div class="f1 item">
            <select>
                <option value="-1">状态</option>
                <option value="0">未结算</option>
                <option value="1">已累积</option>
                <option value="2">已结算</option>
                <option value="3">已清除</option>
            </select>
        </div>
        <div class="f2 item">
            <input type="text" placeholder="开始月份">
        </div>
        <div class="f3 item">
            <input type="text" placeholder="结束月份">
        </div>

        <div class="f10 item">
            <button type="button" class="el-button el-button--primary el-button--small search">
                <span>查询</span>
            </button>
        </div>
    </div>

    <table class="zy-table">
        <thead>
            <tr>
                <th>月份</th>
                <th>有效会员</th>
                <th>达标用户</th>
                <th>代理纯盈利</th>
                <th>代理分红比</th>
                <th>赔率差额</th>
                <th>返水差额</th>
                <th>平台费用</th>
                <th>累积佣金</th>
                <th>代理佣金</th>
                <th>结算状态</th>
            </tr>
        </thead>
        <tbody>
            <tr><td colspan="11">暂无数据</td></tr>
        </tbody>
    </table>
</div>

<script>
    $(".f1 select").selected();
    $(".f2 input").datepicker({format: 'yyyy-mm'});
    $(".f3 input").datepicker({format: 'yyyy-mm'});
    
    ME.query(function() {
        var url = context.config.url + "index.html?referee=" + context.user.user.mobile;
        $("#agentContent .index .agenturl .list a").html(url);

        $("#copyAgentUrl").click(function() {
            superClipBoard.copy(url);
        });
        $(".usernick").html(context.user.user.mobile);
        $("span.balance").html(context.user.user.balance/100);
        if (context.user.user.balance <= 0) {
            $(".balance-zero-clue").show();
        }
        else $(".balance-zero-clue").hide();
    });

    // 计算未结算的总金额
    CMD.stat_referee_query_user({
        state: 0,
        pageNum: 1,
        pageSize: 100,
    }, function(r) {
        var total = 0;
        for (var i in r.list) {
            total += r.list[i].commission;
        }
        $(".weijie-balance").html(total/100);
    });

    // 结算明细
    settleDetail();
</script>
